{
  function _base() {
    interface Person<T> {
      name: string;
      like: T;
    }

    const xiaomin: Person<number> = {
      name: 'xiaomin',
      //like:'11', //报错
      like: 11
    }
    console.log(xiaomin)
  }

  function _function() {
    function person<T>(name: T): T {
      return name
    }
    // person<number>('xiaoming') //报错
    person<string>('xiaoming')
  }

  function _class() {
    class Person<T>{
      public personName: T

      setPersonName(name: T) {
        this.personName = name
      }
    }

    const person = new Person<string>()
    // person.setPersonName(11) //报错
    person.setPersonName('111') // pass
  }

  function _class2() {
    class Person<T, U> {
      public personName: T
      public age: U

      setPersonName(name: T) {
        this.personName = name
      }
      setAge(age: U) {
        this.age = age
      }
    }

    const person = new Person<string, number>()
    // person.setPersonName(11) //报错
    person.setPersonName('111') // pass

    // person.setPersonName('18') //报错
    person.setAge(18) // pass
  }

  function _class3() {

    interface BaseInter {
      name: string;
      age: number;
    }

    function createPerson<T extends BaseInter>(person: T): T {
      return person
    }

    interface Xiaohong {
      name: string;
      age: number;
      count: number;
    }


    // createPerson<string>() //报错
    createPerson<Xiaohong>({ name: 'xiaohong', age: 18, count: 1 })

  }

  // _base()
  // _function()
  // _class()
}
